package com.brooks.demo;

/**
 * 单例模式 双检锁
 *
 * @Author: mihutu
 * @Date: 2020/10/11 21:47
 */

public class DemoSingleton5 {
    private static volatile DemoSingleton5 singleton ;

    private DemoSingleton5() {

    }

    public static DemoSingleton5 getInstance() {
        if (singleton == null){
            synchronized (DemoSingleton5.class) {
                if(singleton == null){
                    singleton = new DemoSingleton5();
                }
            }
        }
        return singleton;
    }
}
